/*
*Copyright 2021-2023 NERCIS
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/

package cn.ac.nercis.pes.repository.mapper.standard;

import cn.ac.nercis.pes.model.standard.*;
import cn.ac.nercis.pes.model.standard.analyze.*;
import cn.ac.nercis.pes.model.standard.asset.AssetAttributeSDTO;
import cn.ac.nercis.pes.model.standard.asset.AssetSDTO;
import cn.ac.nercis.pes.model.standard.asset.PersonnelSDTO;
import cn.ac.nercis.pes.model.standard.asset.SecurityDocumentSDTO;
import cn.ac.nercis.pes.model.standard.evaluation.EvaluationRecordSDTO;
import cn.ac.nercis.pes.model.standard.planning.EvaluationDescSDTO;
import cn.ac.nercis.pes.model.standard.planning.EvaluationMethodSDTO;
import cn.ac.nercis.pes.model.standard.planning.EvaluationRequireSDTO;
import cn.ac.nercis.pes.model.standard.prepare.*;
import cn.ac.nercis.pes.model.standard.proof.EvaluatorQualificationSDTO;
import cn.ac.nercis.pes.model.standard.report.EvaluationReportSDTO;
import cn.ac.nercis.pes.repository.model.evaluation.*;
import cn.ac.nercis.pes.repository.model.project.*;
import cn.ac.nercis.pes.repository.model.report.EvaluationReportDO;
import org.mapstruct.Builder;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

import java.util.Optional;

/**
 * 系统数据导出相关信息类型映射
 *
 * @author zpy
 * @version 1.0.0
 */
@Mapper(componentModel = "spring",
        imports = {
                Optional.class,
                ProjectDO.class
        },
        unmappedTargetPolicy = ReportingPolicy.IGNORE,
        builder = @Builder(disableBuilder = true))
public interface SystemExportMapper {
    SystemExportMapper INSTANCE = Mappers.getMapper(SystemExportMapper.class);

    ProjectSDTO toStandardDTO(ProjectDO entity);

    SystemTargetSDTO toStandardDTO(SystemTargetDO entity);
    SystemSpecialTargetSDTO toStandardDTO(SystemSpecialTargetDO entity);

    SystemProcessSDTO toStandardDTO(SystemProcessDO entity);

    EvaluationProcessSDTO toStandardDTO(EvaluationProcessDO entity);

    EvaluationContentSDTO toStandardDTO(EvaluationContentDO entity);

    EvaluationToolSDTO toStandardDTO(EvaluationToolsDO entity);

    EvaluatorSDTO toStandardDTO(EvaluatorDO entity);

    PasswordServerSDTO toStandardDTO(PasswordServerDO entity);

    SecurityThreatSDTO toStandardDTO(SecurityThreatDO entity);

    EvaluationDescSDTO toStandardDTO(AssetEvaluationDescDO entity);

    EvaluationMethodSDTO toStandardDTO(AssetEvaluationMethodDO entity);

    EvaluationRequireSDTO toStandardDTO(EvaluationRequireDO entity);


    @Mapping(target = "assetId", expression = "java(Optional.of(entity.getAsset()).map(AssetDO::getId).orElse(\"\"))")
    EvaluationRecordSDTO toStandardDTO(EvaluationRecordDO entity);

    UnitEvaluationSDTO toStandardDTO(UnitEvaluationDO entity);

    LayerEvaluationSDTO toStandardDTO(LayerEvaluationDO entity);

    OverallEvaluationSDTO toStandardDTO(OverallEvaluationDO entity);

    @Mapping(target = "recordId", expression = "java(Optional.of(entity.getRecord()).map(EvaluationRecordDO::getId).orElse(\"\"))")
    ResultCorrectionSDTO toStandardDTO(ResultCorrectionDO entity);

    RiskAnalysisSDTO toStandardDTO(RiskAnalysisDO entity);

    UnitRiskAnalysisSDTO toStandardDTO(UnitRiskAnalysisDO entity);

    EvaluationReportSDTO toStandardDTO(EvaluationReportDO entity);

    EvaluatorQualificationSDTO toStandardDTO(EvaluatorQualificationDO entity);

    @Mapping(target = "projectId", expression = "java(Optional.of(entity.getProject()).map(ProjectDO::getId).orElse(\"\"))")
    SystemSDTO toStandardDTO(SystemDO entity);

    SystemEvaluationSDTO toDTO(SystemEvaluationDO entity);

    AssetSDTO toStandardDTO(AssetDO entity);

    AssetAttributeSDTO toDTO(AssetAttributeDO entity);

    PersonnelSDTO toStandardDTO(PersonnelDO entity);

    SecurityDocumentSDTO toStandardDTO(SecurityDocumentDO entity);

}